/***************************************************************************
 **
 **  Copyright (C) 2021 MaMinJie <canpool@163.com>
 **  Contact: https://github.com/canpool
 **           https://gitee.com/icanpool
 **
 **  GNU Lesser General Public License Usage
 **  Alternatively, this file may be used under the terms of the GNU Lesser
 **  General Public License version 3 as published by the Free Software
 **  Foundation and appearing in the file LICENSE.LGPL3 included in the
 **  packaging of this file. Please review the following information to
 **  ensure the GNU Lesser General Public License version 3 requirements
 **  will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
 **
 **  GNU General Public License Usage
 **  Alternatively, this file may be used under the terms of the GNU
 **  General Public License version 2.0 or (at your option) the GNU General
 **  Public license version 3 or any later version approved by the KDE Free
 **  Qt Foundation. The licenses are as published by the Free Software
 **  Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
 **  included in the packaging of this file. Please review the following
 **  information to ensure the GNU General Public License requirements will
 **  be met: https://www.gnu.org/licenses/gpl-2.0.html and
 **  https://www.gnu.org/licenses/gpl-3.0.html.
 **
****************************************************************************/
#include "literibbonwindow.h"
#include "literibbonbar.h"

QLITE_BEGIN_NAMESPACE

class LiteRibbonWindowPrivate
{
public:
    LiteRibbonWindowPrivate();

    void init();

public:
    LiteRibbonWindow *q;
    LiteRibbonBar *m_ribbonBar;
};

LiteRibbonWindowPrivate::LiteRibbonWindowPrivate()
    : m_ribbonBar(Q_NULLPTR)
{

}

void LiteRibbonWindowPrivate::init()
{
    q->setMouseTracking(true);

    m_ribbonBar = new LiteRibbonBar(q);

    q->setMenuWidget(m_ribbonBar);
}

LiteRibbonWindow::LiteRibbonWindow(QWidget *parent)
    : QMainWindow(parent)
    , d(new LiteRibbonWindowPrivate())
{
    d->q = this;
    d->init();

    setObjectName(QLatin1String("qlite_ribbonwindow"));
}

LiteRibbonWindow::~LiteRibbonWindow()
{
    delete d;
}

LiteRibbonBar *LiteRibbonWindow::ribbonBar() const
{
    return d->m_ribbonBar;
}

void LiteRibbonWindow::setFrameless(bool frameless)
{
    if (frameless) {
        setWindowFlags(windowFlags() | Qt::FramelessWindowHint);
    } else {
        setWindowFlags(windowFlags() & ~Qt::FramelessWindowHint);
    }
    d->m_ribbonBar->updateParentFlags();
}

QLITE_END_NAMESPACE
